﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using CUWo.Common.Entities.WoInterface.HttpJsonResult;

/**
 * 创建时间：2014/11/20 12:55:08
 * 作者：yong.blackcore
 * Email：itblackhole@outlook.com
 * QQ：50404503
 */
namespace CUWo.App.CustomControl.News
{
    public class NewsContentTemplateSelector: DataTemplateSelector  
    {  
        public DataTemplate HasImage { get; set; }  
        public DataTemplate NoImage { get; set; }  
  
        //根据newContent的属性，返回所需的DataTemplate  
        public override DataTemplate SelectTemplate(object obj, DependencyObject container)  
        {

            NewsInf item = obj as NewsInf;
            if (item != null)
            {
                if (item.PicInf != null && item.PicInf.Count > 0 && !string.IsNullOrWhiteSpace(item.PicInf[0].Path))
                {
                    return HasImage;
                }
                else
                {
                    return NoImage;
                }
            }
            return base.SelectTemplate(item, container);
        }  
    }  
}
